<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/index.css">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.js"></script>
</head>
<body>
    <h2>搜索</h2>
    <div>
        <input type="text" id="keywords">
        <input type="button" id="btn" value="搜搜">
    </div>
    <ul id="list">
    </ul>

    <script>
        $("#btn").click(()=>{
            let keywords = $('#keywords').val()
            //ajax提交
            $.post({
                url:"http://localhost:3000",
                data:{keywords},
                dataType:"json",
                success:function(res){
                    if(res.code == 200){
                        let htmlstr = ""
                        res.data.searchData.forEach(item=>{
                            htmlstr += `<li><a href="">${item.shopType} ${item.shopPrice}</a></li>`
                        })
                        console.log(res.data.searchData);
                        $("#list").html(htmlstr)
                    }
                }
            })
        })
    </script>
</body>
</html>